//
//  TripDetailItemCell.m
//  Traveling
//
//  Created by 尹桥印 on 15/6/21.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "TripDetailScenicCell.h"
#import "PublicWebViewCtrl.h"
@interface TripDetailScenicCell()
@property (weak, nonatomic) IBOutlet UIImageView *img;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *levelLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *openTimelabel;
@property (weak, nonatomic) IBOutlet UILabel *telLabel;

@property (weak, nonatomic) IBOutlet UILabel *suggestTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *navLabel;


@property (weak, nonatomic) IBOutlet UIButton *lookLineBtn;
@end
@implementation TripDetailScenicCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *identifier = @"TripDetailScenicCell";
    TripDetailScenicCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(void)setDayItem:(TripDetailDayItem *)dayItem{
    _dayItem = dayItem;
    [self.img sd_setImageWithURL:[NSURL URLWithString:dayItem.img]];
    [self.nameLabel setText:dayItem.name];
    [self.levelLabel setText:@"景区等级"];
    [self.priceLabel setText:[NSString stringWithFormat:@"%.2f",dayItem.price]];
    [self.openTimelabel setText:[NSString stringWithFormat:@"开放时间：%@",dayItem.open_time]];
    [self.suggestTimeLabel setText:[NSString stringWithFormat:@"建议游玩时间：%@",dayItem.time]];
    self.telLabel.text = [NSString stringWithFormat:@"电话：%@",dayItem.tel];
    self.addressLabel.text = [NSString stringWithFormat:@"地址：%@",dayItem.address];
    self.navLabel.text = dayItem.navStr;
    if (dayItem.navStr.length>0) {
        self.lookLineBtn.hidden = NO;
    }else{
        self.lookLineBtn.hidden = YES;
    }
}

- (IBAction)lookLineBtnClick:(id)sender {
    if (self.dayItem.nextDayItem) {
        NSString *url = [NSString stringWithFormat:@"%@journey/map.rhtml?start_lat=%f&start_lng=%f&end_lat=%f&end_lng=%f",BASE_URL,self.dayItem.lat,self.dayItem.lng,self.dayItem.nextDayItem.lat,self.dayItem.nextDayItem.lng];
        PublicWebViewCtrl *ctrl = [[PublicWebViewCtrl alloc] initWithUrl:url];
        [self.viewController.navigationController pushViewController:ctrl animated:YES];
    }
}

@end
